package DesignPatterns.Singleton;

//懒汉式 双重检查
//从时间空间上看：以时间换空间
//从线程安全上看：不安全的（所以要加锁synchronized）
public class Singleton3 {
    private volatile static Singleton3 INSTANCE;

    private Singleton3() {

    }

    public static Singleton3 getInstance() {
        if (INSTANCE == null) {
            synchronized (Singleton3.class) {
                if (INSTANCE == null) {
                    INSTANCE = new Singleton3();
                }
            }
        }
        return INSTANCE;
    }
}
